import request from '@/utils/request'

export function query(data) {
  return request({
    url: `/md/devices/queryList`,
    method: 'post',
    data
  })
}

export function getById(id) {
  return request({
    url: `/md/devices/${id}`,
    method: 'get'
  })
}

/**
 * 获取设备自定义数据
 * @param getDeviceCustomData
 */
export function getDeviceCustomData(data) {
  return request({
    url: `/md/commonCustomDatas/getDeviceCustomData`,
    method: 'get',
    params: data
  })
}
/**
 * 获取设备成员信息
 * @param getDeviceTypeVoList
 */
export function getDeviceTypeVoList() {
  return request({
    url: `/md/devices/getDeviceTypeVoList`,
    method: 'get'
  })
}

/**
 * 通过设备查询设备类型可分配和已分配数据
 * @param inquire
 */
export function inquireDevices(data) {
  return request({
    url: `/md/devices/query?device=${data}`,
    method: 'get'
  })
}

export function queryTypeByDevice(data) {
  return request({
    url: `/md/devices/queryType?device=${data}`,
    method: 'get'
  })
}

/**
 * 通过产线查询螺杆组合
 * @param getScrewByLine
 */
export function getScrewByLine(data) {
  return request({
    url: `/md/devices/getScrewByLine`,
    method: 'post',
    data
  })
}

/**
 * 保存
 * @param sitesSave
 */
export function saveDevices(data) {
  return request({
    url: `/md/devices/save`,
    method: 'post',
    data
  })
}

/**
 * 删除
 * @param delete
 */
export function remove(data) {
  return request({
    url: `/md/devices/delete?device=${data}`,
    method: 'delete'
  })
}

export function selectPageDevice(data) {
  return request({
    url: `/md/commonBrowsers/selectPageDevice`,
    method: 'post',
    data: data
  })
}

export function selectCheckAndUpkeepItem(data) {
  return request({
    url: `/mes/deviceItem/query`,
    method: `post`,
    data: data
  })
}

export function outSourceQuery(data) {
  return request({
    url: `/md/outSource/query`,
    method: 'post',
    data: data
  })
}

export function outSourceDelete(data) {
  return request({
    url: `/md/outSource/delete?bo=${data}`,
    method: 'DELETE'
  })
}
// 创建委外单号
export function outSourceCreateCode() {
  return request({
    url: `/md/outSource/createCode`,
    method: 'get'
  })
}
// 保存和更新
export function outSourceSave(data) {
  return request({
    url: `/md/outSource/save`,
    method: 'post',
    data: data
  })
}

// 模糊查询异常单号
export function selectByExceptionCode(exceptionCode) {
  return request({
    url: `/md/outSource/selectByExceptionCode?exceptionCode=${exceptionCode}`,
    method: 'get'
  })
}

// 根据异常单编码查询设备信息
export function selectDeviceInfoByCode(exceptionCode) {
  return request({
    url: `/md/outSource/selectDeviceInfoByCode?exceptionCode=${exceptionCode}`,
    method: 'get'
  })
}

// 根据异常单编码查询设备信息
export function selectInfoByDevice(device) {
  return request({
    url: `/md/outSource/selectInfoByDevice?device=${device}`,
    method: 'get'
  })
}

// 设备履历
export function selectDeviceResume(data) {
  return request({
    url: `/report/deviceResume/query`,
    method: 'post',
    data: data
  })
}
